﻿using System.Windows.Forms;
using Outlook.WorkItems.Extension.Controls.ReportService;

namespace Outlook.WorkItems.Extension.Controls
{
    public class ReportNode : TreeNode
    {
        public ReportNode(CatalogItem item, string reportServer)
        {
            ReportItem = item;
            ReportServer = reportServer;
            ImageIndex = 2;
            SelectedImageIndex = 2;
            Text = item.Name;
        }

        public CatalogItem ReportItem { get; set; }
        public string ReportServer { get; set; }
        public string ReportVersion 
        {
            get
            {
                var node = Parent;
                while (!(node is TeamProjectNode) && node.Parent != null)
                {
                    node = node.Parent;
                }
                var projectNode = node as TeamProjectNode;
                if (projectNode != null)
                    return projectNode.ReportVersion;

                return null;
            }
        }
    }
}
